from django.http import HttpResponse
from django.shortcuts import render_to_response
import datetime

def main_page(request):
    return render_to_response('ex.html', locals())

def hello(request):
    html = "<html><body bgcolor=""#339999"">Hello world<br><a href=""http://127.0.0.1:8000"">BACK</a> </br></body></html>"
    return HttpResponse(html)

def hello_name(request,name):
    html = "<html><body bgcolor=""#339999"">Hello My name is %s.<br><a href=""http://127.0.0.1:8000"">BACK</a> </br></body></html>" % name
    return HttpResponse(html)

def hello_number(request,number):
    count=1
    keepHtml=''
    if int(number)> 10 :
        keepHtml = '<html><body>NUMBER THAN TEN'
    else :
        while(count<=int(number)):
            keepHtml=keepHtml+'<br>Hello world</br>'
            count=count+1
    html = "<html><body bgcolor=""#339999"">%s.<br><a href=""http://127.0.0.1:8000"">BACK</a> </br></body></html>" % keepHtml
    return HttpResponse(html)

def hello_number_name(request,name,number):
    count=1
    keepHtml=''
    if int(number)> 10 :
        keepHtml = 'NUMBER THAN TEN'
    else :
        while(count<=int(number)):
            keepHtml=keepHtml+'<br>Hello world, My name is '+name
            count=count+1
    html = "<html><body bgcolor=""#339999"">%s.<br><a href=""http://127.0.0.1:8000"">BACK</a> </br></body></html>" % keepHtml,
    return HttpResponse(html)
